Package-level declarations
Types
Streaming-vs-final state for UIMessagePart.Text and UIMessagePart.Reasoning (per historical parity gap #30, mirrors v6's TextUIPart.state: 'streaming' | 'done'). Renderers use this to drive a typing cursor / fade animation while the model is still producing the part, and to commit a final layout pass on Done.
Tool call lifecycle in the UI. v6 names — input-streaming / input-available / output-available, NOT v5's partial-call / call / result.
Registry of per-tool renderers. The SDK is UI-framework-agnostic — the registry holds renderer functions that take UIToolInvocation. An application can supply Compose composables, SwiftUI bridge closures, server-rendered nodes, or any other renderer value.
UI-shape message — what the chat surface renders. Carries an ordered list of UIMessageParts (Vercel AI SDK v6 message-parts model). The conversion from ai.torad.aisdk.StreamEvent flow into a growing list of these messages happens in streamToUiMessages.
Typed invocation handle — what a per-tool renderer receives. Carries the typed input + output via the tool's own serializers.
Functions
Top-level builder for ToolPartHandlerRegistry.
Convert a list of UI-shape UIMessages back into the model-shape ModelMessage list the LLM expects on the next turn. Mirrors v6's convertToModelMessages (per historical parity gap #5).
Type-safe extraction at the UI render seam. Pulls a typed TOutput out of UIMessagePart.ToolUI.output. Returns null if state isn't OutputAvailable (caller should branch on state first).
Convert a raw agent StreamEvent flow into a flow of growing UIMessage snapshots. Each emission is the current full state of the assistant message being built — caller's StateFlow<List<UIMessage>> just replaces the in-flight message on each emission.
Bridge an agent StreamEvent flow to the v6 UI-message-stream wire protocol: each emission is a UIMessageChunk JSON object (e.g. { "type": "text-delta", "id": "...", "delta": "..." }) ready to be framed as an SSE data: line and consumed by a JS useChat client. Events with no wire counterpart (response-metadata, tool-input-end, raw) are dropped.